package com.ajk.server.dao;


import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;

import com.ajk.server.dao.provider.PartProvider;
import com.ajk.server.model.ReportPart;
import com.ajk.server.model.ReportPartAdvice;
import com.ajk.server.model.ReportPartHealthy;

public interface PartMapper {
	
	@Insert("insert into t_report_part (name,part_image,filename,part_no) values (#{name},#{partImage},#{filename},#{partNo})")
	@Options(useGeneratedKeys=true)
	public Integer insertPart(ReportPart reportPart);
	
	@UpdateProvider(type=PartProvider.class,method="update")
	public Integer updatePart(ReportPart reportPart);
	
	@SelectProvider(type=PartProvider.class,method="getPartList")
	public List<ReportPart> getPartList(ReportPart reportPart);
	
	@Select("select * from t_report_part where id = #{id}")
	public ReportPart getPartById(Integer id);
	
	@Insert("insert into t_report_part_advice(part_id,level,content) value (#{partId},#{level},#{content})")
	public Integer insertPartAdvice(ReportPartAdvice advice );
	
	@Update("update t_report_part_advice set content = #{content} where level = #{level} and part_id = #{partId}")
	public Integer updatePartAdvice(ReportPartAdvice advice);
	
	@Select("select * from t_report_part_advice where part_id = #{partId} order by level asc")
	public List<ReportPartAdvice> getPartAdviceList(Integer partId);
	
	@Select("select * from t_report_part_advice where part_id = #{partId} and level = #{level}")
	public ReportPartAdvice getPartAdviceByLevelAndPartId(@Param("partId") Integer partId,@Param("level") Integer level);
	
	@Insert("insert into t_report_part_healthy(part_id,content) values (#{partId},#{content})")
	public Integer insertPartHealthy(ReportPartHealthy reportPartHealthy);
	
	@Update("update t_report_part_healthy set content = #{content} where part_id = #{partId}")
	public Integer updatePartHealthy(ReportPartHealthy reportPartHealthy);
	
	@Select("select * from t_report_part_healthy where part_id = #{partId}")
	public ReportPartHealthy getReportPartHealthy(Integer partId);
	

}
